function getFirstWeekDay(year, month) {
    //日历一号是星期几
    const date = new Date(year, month - 1, 1);
    return date.getDay();
}
function getMonthDayCount(year, month) {
    const date = new Date(year, month, 0);
    //当月是多少天
    return date.getDate();
}
function getLastMonthRestCount(year, month) {
    const date = getFirstWeekDay(year, month);
    //上个月一号是星期几
    let lastDate = getMonthDayCount(year, month - 1);
    //上个月是多少天
    const resDays = [];
    while (resDays.length < date) {
        //假如是星期五，那么前面就是有上个月的后4天
        resDays.unshift(lastDate--);
    }
    return resDays;
}
function getNextMonthRestDays(year, month) {
    //日历中结尾需要安放多少天，即下一月前几天灰色的日期
    const thisMonthDaysCount = getMonthDayCount(year, month);
    const thisMonthWeekDay = getFirstWeekDay(year, month);
    const nextMonthRestDays = 42 - thisMonthDaysCount - thisMonthWeekDay; //一页日历42天，减去本月的天数，再减去本月第一天是星期几，则可以得到本页月历后面的日期
    const restDays = [];
    for (let i = 1; i <= nextMonthRestDays; i++) {
        restDays.push(i);
    }
    return restDays;
}
function getDateInfo(timeStamp) {
    var date = timeStamp ? new Date(timeStamp) : new Date(); //当前日期
    console.log([//年月日
    date.getFullYear(),
    date.getMonth() + 1,
    date.getDate()
]);
    return [//年月日
        date.getFullYear(),
        date.getMonth() + 1,
        date.getDate()
    ];
}
function getFormatData(year, month, date) {
    const dateArr = [year, month, date];
    for (let i = 1; i < dateArr; i++) {
        dateArr[i] < 10 && (dateArr[i] = "0" + dateArr[i])
    }
    console.log(dateArr.join["-"]);
    return dateArr.join["-"]

}

export {getFirstWeekDay,getMonthDayCount,getLastMonthRestCount,getNextMonthRestDays,getDateInfo,getFormatData}